home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Online / opennap / upload_complete.c < prev    next >
C/C++ Source or Header  |  2001-06-08  |  2KB  |  71 lines

  1. /* Copyright (C) 2000-1 drscholl@users.sourceforge.net
  2.    This is free software distributed under the terms of the
  3.    GNU Public License.  See the file COPYING for details.
  4.  
  5.    $Id: upload_complete.c,v 1.31 2001/02/15 08:39:45 drscholl Exp $ */
  6.  
  7. #include <string.h>
  8. #include "opennap.h"
  9. #include "debug.h"
  10.  
  11. /* 608 <recip> "<filename>" */
  12. /* a client sends this message when another user has requested a file from
  13.    them and they are accepting the connection.  this should be a
  14.    response to the 607 upload request */
  15. HANDLER (upload_ok)
  16. {
  17.     char   *av[2];
  18.     USER   *recip;
  19.     DATUM  *info = 0;
  20.     int     ac;
  21.  
  22.     (void) tag;
  23.     (void) len;
  24.     CHECK_USER_CLASS ("upload_ok");
  25.     ASSERT (validate_connection (con));
  26.     if ((ac = split_line (av, sizeof (av) / sizeof (char *), pkt)) != 2)
  27.     {
  28.     log ("upload_ok(): malformed message from %s", con->user->nick);
  29.     print_args (ac, av);
  30.     unparsable (con);
  31.     return;
  32.     }
  33.     recip = hash_lookup (Users, av[0]);
  34.     if (!recip)
  35.     {
  36.     nosuchuser (con);
  37.     return;
  38.     }
  39.     /* pull the hash from the data base */
  40.     info = hash_lookup (con->uopt->files, av[1]);
  41.     if (!info)
  42.     {
  43.     send_cmd (con, MSG_SERVER_NOSUCH, "Not sharing that file");
  44.     return;
  45.     }
  46.     if (con->user->port == 0)
  47.     {
  48.     /* firewalled user, give the info back to the uploader */
  49.     send_cmd (con, MSG_SERVER_UPLOAD_FIREWALL /* 501 */ ,
  50.           "%s %u %hu \"%s\" %s %d",
  51.           recip->nick, recip->ip, recip->port, av[1],
  52. #if RESUME
  53.           info->hash,
  54. #else
  55.           "00000000000000000000000000000000",
  56. #endif
  57.           recip->speed);
  58.     }
  59.     else
  60.     /* recipient of this message may be on a remote server, use
  61.        send_user() here */
  62.     send_user (recip, MSG_SERVER_FILE_READY, "%s %u %hu \"%s\" %s %d",
  63.            con->user->nick, con->user->ip, con->user->port, av[1],
  64. #if RESUME
  65.            info->hash,
  66. #else
  67.            "00000000000000000000000000000000",
  68. #endif
  69.            con->user->speed);
  70. }
  71.